<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	//系统首页
    public function index(){

        $category = D('Category')->getTree();
        $lists    = D('Document')->position(C('INDEX_VAL'),null,null,'id,name,title,cover_id,category_id');
		
        $listsGroup = array();
        $listId = array();
        
        foreach ($lists as $vo){
        	$listsGroup[$vo['category_id']][] = $vo;
        	$listId[]=$vo['id'];//条件
        }
        $this->assign('listGroup',$listsGroup);
        
		//获取DocumentArticleydb的内容
        $map ['id'] = array ('in',$listId);        
        $ArticleydbList = M('DocumentArticleydb')->where($map)->select();
        $ArticleydbListGroup = array();
        foreach ($ArticleydbList as $vo){
        	$ArticleydbListGroup[$vo['id']] = $vo;
        }
                
        $this->assign('ArticleydbListGroup',$ArticleydbListGroup);
        
		//dump($listsGroup);
        
        
   		$this->assign('categorylist',$category[0]['_']);
        $this->assign('category',$category);//栏目
        $this->assign('lists',$lists);//列表
        $this->assign('page',D('Document')->page);//分页

                 
        $this->display();
    }

}